<%--
*
* 错误提示页面
*
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isErrorPage="true"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>错误提示页面</title>
	</head>
	<%
		exception.printStackTrace();//打印到控制台
	%>	
	<body>
		<script type="text/javascript">
			window.focus();
		</script>
		<fieldset>
			<legend>
				以下原因导致失败:
			</legend>
			<span style="color: red;font-size: 12px;"><%=getStackTrace(exception)%></span>
		</fieldset>
		<%!
			String getStackTrace(Throwable throwable){
		        if(throwable == null)
		            return "";
		        StringBuffer strStackTrace = new StringBuffer();
		        strStackTrace.append(throwable);
		        strStackTrace.append("<br>");
		        StackTraceElement stackTraceElements[] = throwable.getStackTrace();
		        StackTraceElement astacktraceelement[] = stackTraceElements;
		        int i = 0;
		        for(int j = astacktraceelement.length; i < j; i++)
		        {
		            StackTraceElement stackTraceElement = astacktraceelement[i];
		            strStackTrace.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
		            strStackTrace.append("\tat ");
		            strStackTrace.append(stackTraceElement.toString());
		            strStackTrace.append("<br>");
		        }
		
		        Throwable ourCause = throwable.getCause();
		        if(ourCause != null)
		        {
		            strStackTrace.append("Caused by: ");
		            strStackTrace.append(getStackTrace(throwable.getCause()));
		        }
		        return strStackTrace.toString();
		    } 
		%>		
	</body>
</html>
